function updateCompany(companyId,parentCompanyId,companyName){
	
	sendUpdateCompanyRequest(companyId,parentCompanyId,companyName);	
}

function sendUpdateCompanyRequest(companyId,parentCompanyId,oldCompanyName){
	var name = $("#company_companyName_update").val();
	var telephone = $("#company_telephone_update").val();
	var fax = $("#company_fax_update").val();
	var email = $("#company_email_update").val();
	var address = $("#company_address_update").val();
	var postCode = $("#company_postCode_update").val();;
	var remark = $("#company_remark_update").val();
	var params = {	"companyAddEdit.companyId":companyId,
			"companyAddEdit.parentCompanyId":parentCompanyId,
			"companyAddEdit.companyName":name,
			"companyAddEdit.telephone":telephone,
			"companyAddEdit.fax":fax,
			"companyAddEdit.email":email,
			"companyAddEdit.address":address,
			"companyAddEdit.postCode":postCode,
			"companyAddEdit.remark":remark}; 
	
	//check name
	var companyName=trim(name);	
	$.post("admin/ajaxCheckCompanyName.action", {"companyName":companyName,"companyId":companyId}, function(data){
		if(!isTimeout(data,true)){	
			if(data>0&&name!=oldCompanyName){
				alert("单位名称已经存在,请修改单位名称");
			}else{
				if(checkCompanyInfo(name,telephone,fax,email,address,postCode,remark)){
					
					$.post("admin/ajaxCompanyUpdate.action",params,function(data2){		
						//set to div *********************************
						if(data2>0){
							showAlertDialogue('修改成功',forwardToNewPage,'companyExcutePagination.action');
							//forward to new page	
							}else{
								showAlertDialogue('修改失败');
							}
					});
				}
			}
		}
	}
	);	
}
function forwardToNewPage(url){
	$("#form1").attr("action",url);
    $("#form1").submit();
}
function checkCompanyInfo(name,telephone,fax,email,address,postCode,remark){
	
	return checkName(trim(name)) && 
			checkTel(trim(telephone)) &&
			checkFax(trim(fax)) &&
			checkEmail(trim(email)) &&
			checkAddress(trim(address)) &&
			checkPostCode(trim(postCode)) &&
			checkRemark(trim(remark));
}